package com.loan.log.environment;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

/**
 * @author shiguang on 2022/6/22 14:15
 */
public class SDKSystemPropertiesApplicationLister implements ApplicationListener<ContextRefreshedEvent> {

    private String systemId = "";

    public SDKSystemPropertiesApplicationLister() {
    }

    public SDKSystemPropertiesApplicationLister(String systemId) {
        this.systemId = systemId;
    }

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        String systemId = System.getProperty("SYSTEM_ID");
        if (systemId == null || "".equals(systemId.trim())){
            System.setProperty("SYSTEM_ID",this.systemId);
        }
    }
}
